home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: uu4news.netcom.com!zodiac!szh
- From: szh@zcon.com (Syed Zaeem Hosain)
- Subject: Re: Watch out! C "gotcha!"
- Message-ID: <1996Feb15.200810.14419@zcon.com>
- Sender: szh@zcon.com (Syed Zaeem Hosain)
- Nntp-Posting-Host: zodiac
- Reply-To: szh@zcon.com
- Organization: Z Consulting Group
- References: <62ttN_YbnTB@softsite.co.at>
- Date: Thu, 15 Feb 1996 20:08:10 GMT
-
- In article <62ttN_YbnTB@softsite.co.at>, wsog@softsite.co.at (Walter Sommergruber) writes:
- >Michael Schwarz (mschwarz@winternet.com) wrote on 14.02.96
- >about "Watch out! C "gotcha!"":
- >
- >> switch (x)
- >> {
- >> case 1:
- >> printf("It's 1.\n");
- >> break;
- >>
- >> defalt:
- >> printf("It's not 1.\n");
- >> break;
- >> }
- >[snip]
- >> My point is that several compilers we tried this on compiled thismistake
- >> with no error or warning. If you, like so many of us, do not get enough
- >> time to completely coverage test your code, this mistake can really bite
- >> you on the behind. Your "default" code will never be executed!
- >
- >That's no mistake - it's valid C.
-
- I think the original poster *realized* that it is valid C code. He was
- commenting on the fact that it was an unintentional programming error
- that could easily occur. And you would not find out about it till the
- operation of the code broke - perhaps in a rare circumstance, when the
- default code actually was supposed to be invoked and did not.
-
- >"defalt:" is interpreted as a
- >label for a potential goto. You write for instance:
- > case 1:
- > printf("abc");
- > if( x ) goto defalt;
- > printf("def");
- > defalt:
- > printf("something else");
-
- Z
-
-
- --
- -------------------------------------------------------------------------
- | Syed Zaeem Hosain P. O. Box 610097 (408) 441-7021 |
- | Z Consulting Group San Jose, CA 95161 szh@zcon.com |
- -------------------------------------------------------------------------
-